/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package times.persistence.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import times.persistence.entities.AnimalSpecies;
import times.persistence.entities.PriceSourceSlaughterHeader;

/**
 *
 * @author Administrator
 */
@Entity
@Table(name = "price_source")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PriceSource.findAll", query = "SELECT p FROM PriceSource p"),
    @NamedQuery(name = "PriceSource.findById", query = "SELECT p FROM PriceSource p WHERE p.id = :id"),
    @NamedQuery(name = "PriceSource.findByName", query = "SELECT p FROM PriceSource p WHERE p.name = :name"),
    @NamedQuery(name = "PriceSource.findByContactName", query = "SELECT p FROM PriceSource p WHERE p.contactName = :contactName"),
    @NamedQuery(name = "PriceSource.findByPhone", query = "SELECT p FROM PriceSource p WHERE p.phone = :phone"),
    @NamedQuery(name = "PriceSource.findByEmail", query = "SELECT p FROM PriceSource p WHERE p.email = :email")})
public class PriceSource implements Serializable {
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "priceSourceId")
    private List<PriceSourceSlaughterHeader> priceSourceSlaughterHeaderList;
    @JoinColumn(name = "animal_species_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private AnimalSpecies animalSpeciesId;
   
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "name")
    private String name;
    @Column(name = "contact_name")
    private String contactName;
    @Column(name = "phone")
    private String phone;
    @Column(name = "email")
    private String email;
    @Column(name = "username")
    private String username;
    @Column(name = "password")
    private String password;

    public PriceSource() {
    }

    public PriceSource(Integer id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }



    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getContactName() {
        return contactName;
    }

    public void setContactName(String contactName) {
        this.contactName = contactName;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PriceSource)) {
            return false;
        }
        PriceSource other = (PriceSource) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return name;
    }

    public AnimalSpecies getAnimalSpeciesId() {
        return animalSpeciesId;
    }

    public void setAnimalSpeciesId(AnimalSpecies animalSpeciesId) {
        this.animalSpeciesId = animalSpeciesId;
    }

    @XmlTransient
    public List<PriceSourceSlaughterHeader> getPriceSourceSlaughterHeaderList() {
        return priceSourceSlaughterHeaderList;
    }

    public void setPriceSourceSlaughterHeaderList(List<PriceSourceSlaughterHeader> priceSourceSlaughterHeaderList) {
        this.priceSourceSlaughterHeaderList = priceSourceSlaughterHeaderList;
    }

  
    
}
